package com.jl.jlapp.mvp.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.OrderMessageListAdapter;
import com.jl.jlapp.eneity.OrderMessageListModel;
import com.jl.jlapp.eneity.OrderMessageListModel.ResultDataBean;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.ArrayList;
import java.util.List;

public class OrderMessageListActivity extends Activity {
    @BindView(R.id.no_message_linear)
    LinearLayout noMessageLinear;
    OrderMessageListAdapter orderMessageListAdapter;
    @BindView(R.id.order_message_recycler_view)
    RecyclerView orderMessageRecyclerView;
    private ProgressDialog progressDialog;
    List<OrderMessageListModel.ResultDataBean> resultDataBeanList = new ArrayList();
    List<OrderMessageListModel.ResultDataBean> shouldShowResultDataBeanList = new ArrayList();
    int userId = -1;

    private void getShouldShowList(List<OrderMessageListModel.ResultDataBean> paramList) {
        this.shouldShowResultDataBeanList.clear();
        int i = 0;
        while (i < paramList.size()) {
            this.shouldShowResultDataBeanList.add(paramList.get(i));
            i += 1;
        }
    }

    private void setAdapter() {
        if (this.orderMessageListAdapter == null) {
            this.orderMessageRecyclerView.setLayoutManager(new LinearLayoutManager(this));
            this.orderMessageListAdapter = new OrderMessageListAdapter(R.layout.order_message_list_item_layout, this.shouldShowResultDataBeanList);
            this.orderMessageRecyclerView.setAdapter(this.orderMessageListAdapter);
            this.orderMessageListAdapter.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
                    Intent intent = new Intent(OrderMessageListActivity.this, OrderDetailActivity.class);
                    intent.putExtra("orderId", ((OrderMessageListModel.ResultDataBean) OrderMessageListActivity.this.shouldShowResultDataBeanList.get(paramAnonymousInt)).getOrderId());
                    OrderMessageListActivity.this.startActivity(intent);
                }
            });
        } else {
            this.orderMessageListAdapter.notifyDataSetChanged();
        }
    }


    public void buildProgressDialog() {
        if (this.progressDialog == null) {
            this.progressDialog = new ProgressDialog(this);
            this.progressDialog.setProgressStyle(0);
        }
        this.progressDialog.setMessage("加载中");
        this.progressDialog.setCancelable(true);
        this.progressDialog.show();
    }

    public void cancelProgressDialog() {
        if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
            this.progressDialog.dismiss();
        }
    }

    public void getOrderStateDetailList(Integer paramInteger) {
        Net.get().getOrderStateDetailList(paramInteger.intValue())
                .compose(Transformer.<OrderMessageListModel>switchSchedulers())
        .subscribe(new CommonObserver<OrderMessageListModel>() {
            @Override
            protected void onError(String errorMsg) {

            }

            @Override
            protected void onSuccess(OrderMessageListModel orderMessageListModel) {

            }
        });
    }

    @OnClick({R.id.icon_return})
    public void onClick(View paramView) {
        finish();
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_order_list_message);
        ButterKnife.bind(this);
    }

    protected void onResume() {
        super.onResume();
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", -1);
        buildProgressDialog();
        if (this.userId > 0) {
            getOrderStateDetailList(Integer.valueOf(this.userId));
            return;
        }
        Toast.makeText(this, "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(this, LoginActivity.class));
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/OrderMessageListActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */